package us.icitap.cm.business.entities;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.eclipse.persistence.annotations.Customizer;

import us.icitap.cm.utils.MyCustomizer;

@Entity
@Customizer(MyCustomizer.class)
@Table(name="CASE_OFFICER", schema="MPC")
public class CaseOfficer implements Serializable {

	@Id
	@Column(insertable=false, updatable = false)
	private Integer id;
	
	@ManyToOne
	@JoinColumn(name="OFFICER_ID")
	private Officer officer;
	
	@OneToOne
	@JoinColumn(name="ID",nullable=false)
	private AppEntity appEntity;

	@Column(name="PHONE_NO", length=30)
	private String phoneNo;

	@ManyToOne
	@JoinColumn(name="CASE_INVOLVEMENT_ID")
	private AppList caseInvolvement;
	
	public CaseOfficer() {
		super();
	}

	public CaseOfficer(CaseOfficer caseOfficer) {
		this.officer = caseOfficer.getOfficer();
		
				
		
	}
	
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Officer getOfficer() {
		return officer;
	}

	public void setOfficer(Officer officer) {
		this.officer = officer;
	}

	public AppEntity getAppEntity() {
		return appEntity;
	}

	public void setAppEntity(AppEntity appEntity) {
		this.appEntity = appEntity;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((officer == null) ? 0 : officer.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		CaseOfficer other = (CaseOfficer) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (officer == null) {
			if (other.officer != null)
				return false;
		} else if (!officer.equals(other.officer))
			return false;
		return true;
	}

	public boolean myEquals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		CaseOfficer other = (CaseOfficer) obj;
		if (officer == null) {
			if (other.officer != null)
				return false;
		} else if (!officer.equals(other.officer))
			return false;
		return true;
	}
	
	@Override
	public String toString() {
		return officer.getPoliceId() + ", " + officer.getNameSurname();
	}

	public String getPhoneNo() {
		return phoneNo;
	}

	public void setPhoneNo(String phoneNo) {
		this.phoneNo = phoneNo;
	}

	public AppList getCaseInvolvement() {
		return caseInvolvement;
	}

	public void setCaseInvolvement(AppList caseInvolvement) {
		this.caseInvolvement = caseInvolvement;
	}
	
	
	
}
